# 对外开放的api接口

from fastapi import APIRouter

from src.crud import *

router = APIRouter()


@router.get("/categories", response_model=ResponseModel)
async def getCategories(lang: str = "zh-CN"):
    return selectAllCategories(lang)


@router.get("/entries", response_model=ResponseModel)
async def getEntries(cid: int, lang: str = "zh-CN"):
    return selectEntries(cid, lang)


@router.get("/entry", response_model=ResponseModel)
async def getEntry(eid: int, lang: str = "zh-CN"):
    return selectEntry(eid, lang)


@router.get("/search", response_model=ResponseModel)
async def getSearchRes(kwd: str, lang: str = "zh-CN"):
    return selectSearchKeyword(kwd, lang)